_package("scroll.page");

_import("caf.ui.Page");
_import("caf.mui.ScrollView");

_class("HomePage", Page, function(){
	this._init = function(){
		_super._init.call(this);
    this._scrollview = null;
	};
	this.create = function(parent){
		var obj = this.createTplElement(parent, "home.xml");
		this.init(obj);
		return obj;
	};
	this.init = function(){
		_super.init.apply(this, arguments);
		this.initComponents();
		this.initActionElements();

    this._scrollview = new ScrollView();
    this._scrollview.bind($E("home_content_wrapper"), {
        "parent": this,
        "id"    : "scroll1"
    });
    this.addListener(this._scrollview, "scrollEnd", this._scrollview, "onDefaultScrollEnd");

    //demo code
    this.addListener(this._scrollview, "scrollEnd", null, function(){
      document.querySelector(".scroller").style.top
      console.log(this);
    })
	};
	this.dispose = function(){
		_super.dispose.apply(this);
    this._scrollview.dispose();
    this._scrollview = null;
	};
});